apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: grafanadashboarddefinitions.deckhouse.io
  labels:
    heritage: deckhouse
    module: prometheus
    app: grafana
spec:
  group: deckhouse.io
  scope: Cluster
  names:
    plural: grafanadashboarddefinitions
    singular: grafanadashboarddefinition
    kind: GrafanaDashboardDefinition
  preserveUnknownFields: false
  versions:
    - name: v1alpha1
      served: true
      storage: true
      schema: &schema
        openAPIV3Schema:
          type: object
          description: |
            The resource for storing and managing Grafana dashboards.
          required:
            - spec
          properties:
            spec:
              type: object
              required:
                - folder
                - definition
              properties:
                folder:
                  type: string
                  description: |
                    What folder to use for a dashboard. If the folder does not exist, it will be created.
                  x-doc-examples: ['My Folder']
                definition:
                  type: string
                  pattern: '^[ \t\n]*\{(.|\n)*\}[ \t\n]*$'
                  description: |
                    The dashboard's JSON manifest.

                    > **Caution!** Make sure that there is no "local" `id` (at the `.id` address) in the manifest in addition to the `uid`.
      additionalPrinterColumns: &additionalPrinterColumns
        - jsonPath: .spec.folder
          name: Folder
          description: 'Folder in Grafana.'
          type: string
    - name: v1
      served: true
      storage: false
      schema: *schema
      additionalPrinterColumns: *additionalPrinterColumns
